<template>

  <el-button size="default" type="default" @click="backToList()">返回</el-button>
  <el-button size="default" type="default" @click="getDetail()">获取数据</el-button>
    <el-descriptions column="2">
        <el-descriptions-item label="头像">
<!--            <el-image :src="dataDetail.headUrl"></el-image>-->
        </el-descriptions-item>

    </el-descriptions>

    <el-descriptions column="3">
        <el-descriptions-item label="id：">{{ dataDetail.id }}</el-descriptions-item>
        <el-descriptions-item label="标题：">{{ dataDetail.title }}</el-descriptions-item>
<!--        <el-descriptions-item label="文件：">{{ dataDetail.fileList }}</el-descriptions-item>-->
        <el-descriptions-item label="图片：">{{ dataDetail.pictureUrlList }}</el-descriptions-item>
        <el-descriptions-item label="限制人数：">{{ dataDetail.limitPersonNum }}</el-descriptions-item>
        <el-descriptions-item label="参与条件：">{{ dataDetail.condition }}</el-descriptions-item>
        <el-descriptions-item label="地点：">{{ dataDetail.place }}</el-descriptions-item>
        <el-descriptions-item label="状态：">{{ statusMap.get(dataDetail.status) }}</el-descriptions-item>
        <el-descriptions-item label="开始时间：">{{ dataDetail.openTime }}</el-descriptions-item>
        <el-descriptions-item label="发布时间：">{{ dataDetail.gmtCreateTime }}</el-descriptions-item>
        <el-descriptions-item label="驳回原因：" v-if="dataDetail.status === 6">{{ dataDetail.gmtCreateTime }}</el-descriptions-item>
    </el-descriptions>
    <el-descriptions>
      <el-descriptions-item label="描述：">{{ dataDetail.content }}</el-descriptions-item>
    </el-descriptions>

    <el-descriptions>
      <el-descriptions-item label="文件：">{{ dataDetail.fileList }}</el-descriptions-item>
    </el-descriptions>

    <el-descriptions>

        <el-descriptions-item label="报名人：">{{ dataDetail.gmtCreateTime }}</el-descriptions-item>

    </el-descriptions>


    <el-form-item>
        <el-button type="primary" @click="changeSt('2')">
            审核通过
        </el-button>
        <el-button type="danger" @click="changeSt('6')">
            驳回
        </el-button>
        <el-button type="danger" @click="changeSt('4')">
            取消
        </el-button>
    </el-form-item>


</template>

<script setup>

import { ref } from 'vue'
import {Plus} from "@element-plus/icons-vue";
import {changeStatus, getPostList} from "../../../api/request";
import {ElMessage} from "element-plus";
import {useRoute, useRouter} from "vue-router/dist/vue-router";

const loginUserId = ref("")
const loginUserName = ref("")
const router = useRouter()
const route = useRoute()

const typeMap = ref(new Map([
    ['1', "求助"],
    ['2', "教程"],
    ['3', "讨论"],
    ['4', "分享"],
    ['5', "其他"]
]))

const reqParam = ref({
    loginUserId: "",
    loginUserName: "",
    creatorId: "",
    creatorName: "",
    gmtCreateTime: "",
    modifierId: "",
    modifierName: "",
    gmtModifyTime: "",
    id: "",
    title: "",
    type: "",
    content: "",
    tagIds: "",
    tagIdList: [],
    fileUrls: "",
    fileUrlList: [],
    status: "",
    backReason: "",
    saveType: ""
})

const statusMap = ref(new Map([
    ['0', "待提交"],
    ['1', "待审核"],
    ['2', "报名阶段"],
    ['3', "活动进行中"],
    ['4', "取消"],
    ['5', "圆满结束"],
    ['6', "被驳回"]
]))


const dataDetail = ref({
    id: "",
    title: "",
    content: "",
    fileList: [],
    pictureUrlList: [],
    limitPersonNum: 0,
    openTime: "",
    place: "",
    condition: "",
    status: "",
    backReason: "",
    creatorId: "",
    creatorName: "",
    gmtCreateTime: "",
    modifierId: "",
    modifierName: "",
    gmtModifyTime: ""
})

const tagList = ref([])



async function getDetail() {
  let resp = await getPostList({
    // id: id.values()
    id: route.params.id
  }, "/activity/detail")
  console.log(resp)
  dataDetail.value = resp.data
}

async function changeSt(statusId) {
  let resp = await changeStatus({
    id: route.params.id,
    status: statusId
  }, "/activity/update")
  if (resp.code === 200) {
    ElMessage.success("更新成功")
    await getDetail()
  }else {
    ElMessage.error("更新失败")
  }
}

function backToList() {
  router.back()
}
function wait() {
  ElMessage.info("功能开发中，敬请期待....")
}



</script>


<style scoped>

</style>